<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%   
String path = request.getContextPath();   
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";   
%> 

<!DOCTYPE html>
<html lang="zh-CN">
   <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- IE兼容模式 通知 IE 采用其所支持的最新的模式 -->
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<!-- 360,qq浏览器等多核浏览器，优先采用webkit -->
	<meta name="renderer" content="webkit">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="xesj">
	<meta http-equiv="description" content="xesj">
    <link rel="stylesheet" href="<%=basePath %>static/css/log_reg.css" />
    <link rel="icon" type="image/x-ico" href="<%=basePath %>static/images/logo_icon.jpg"> 
	<!-- 引入 Bootstrap -->
	<link href="<%=basePath %>static/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet">
	<script src="<%=basePath %>static/js/jquery-1.11.3.min.js"></script>
	<script src="<%=basePath %>static/js/util.js"></script>
	<script src="<%=basePath %>static/js/main.js"></script>
	<script type="text/javascript" src="<%=basePath %>static/js/maxModal/maxModal.js" ></script>
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>登录</title>
	     <style>  
            .common_button{
			background-color: #5d5d5e;
		    color: #fff;
		    display: inline-block;
		    margin-bottom: 0;
		    font-weight: normal;
		    text-align: center;
		    vertical-align: middle;
		    touch-action: manipulation;
		    cursor: pointer;
		    background-image: none;
		    border: 1px solid #5d5d5e;
		    white-space: nowrap;
		    padding: 6px 12px;
		    font-size: 15px;
		    line-height: 1.42857143;
		    border-radius: 6px;
		    user-select: none;
		    width: 104px;
		    height: 40px;
		}
        </style>  
    
   
  </head>
  
  <body>
	 <div class="bg">
		<img src="<%=basePath %>static/images/bg.jpg" width="100%" height="100%"/>
	 </div>
	 <div class="bgCover"></div> 
    <div class="loginBox animated flipInX">
        <div class="cover"></div>
         <div class="loginCon animated zoomInUp">
		    <form  action="<%=basePath %>login.do" name="submitForm" id="submitForm" method="post" >
				<div class="login_info">
				  <div class="login_item">
				    <label  >帐号</label>
				    <input type="text" class="form-control" name="loginName" id="loginName" placeholder="帐号">
				  </div>
				  <div class="login_item">
				    <label >密码</label>
				    <input type="password" class="form-control" name="loginPassWord"  id="loginPassWord" placeholder="密码">
				  </div>
	   			  <div class="login_btn">
			          <button  type="button" id="login_in" onclick="toLogin()" >登录</button>
			          <button  type="button" id="login_reset"  onclick="window.location.href='<%=basePath %>registController/goRegistPage.do'">注册</button>	          
	              </div>
	            </div>
	            <div class="login_other">
	  				<span>${errMsg}</span>
	  			</div>
			</form>
		</div>
   </div>
  
  <script type="text/javascript">
  $(function () {
      if ("${errMsg }") {
          $(".login_other").show();
          setTimeout(function () {
              $(".login_other").hide();
          }, 2000)
      }

      // 监听验证为4位后自动登录
      /* $("#code").bind('input porpertychange',function(){
          var codelength = $("#code").val().length;
          if (codelength == 4) {
              toLogin();
          }
      }); */
  });
	
  //登陆
  function toLogin() {
      //验证用户名
      var loginName = $("input[name='loginName']").val();
      if (!loginName) {
          //	alert("用户名不能为空！");
          $("input[name='loginName']").on("focus", function () {
              $(this).MaxTip({
                  "content": "用户名不能为空！",
                  "side": "right"
              }); //.tooltip("show");
          }).focus();
          return false;
      } else {
      	 sessionStorage.setItem('loginName',loginName);
      }

      //验证密码
      var userpsd = $.trim($("input[name='loginPassWord']").val());
      if (!userpsd) {
          $("input[name='loginPassWord']").on("focus", function () {
              $(this).MaxTip({
                  "content": "密码不能为空！",
                  "side": "right"
              }); //.tooltip("show");
          }).focus();
          return false;
      } else {

      }

      //验证码
     /*  var code = $("input[name='code']").val();
      if (!code) {
          $("input[name='code']").on("focus", function () {
              $(this).MaxTip({
                  "content": "验证码不能为空！",
                  "side": "right"
              }); //.tooltip("show");
          }).focus();
          return false;
      } else {

      } */
      $("#submitForm").submit();
  };
 
  //重置
  function loginReset() {
      $(".form-control").val("");
  };

  //忘记密码
  function lostPsd() {

  }
  //登陆注册页居中
  loginWrapInit();


  $(function () {

      $(window).on("resize", function () {
          loginWrapInit();
      });

      if (getBrowerType() == "IE8") {
          $(".bg").append("<img src='static/images/bg.jpg' style='width:100%;height:100%;' />");
      }

      //用户名绑定回车事件
      $(".form-control").eq(0).on("keydown", function (event) {
          var ev = event || window.event;
          var code = ev.keyCode || ev.which;
          if (code == "13") {
              $(".form-control").eq(1).focus();
          }
      });
      //密码绑定回车事件
      $(".form-control").eq(1).on("keydown", function (event) {
          var ev = event || window.event;
          var code = ev.keyCode || ev.which;
          if (code == "13") {
              $(".form-control").eq(2).focus();
          }
      })
      //验证码绑定回车事件
      $(".form-control").eq(2).on("keydown", function (event) {
          var ev = event || window.event;
          var code = ev.keyCode || ev.which;
          if (code == "13") {
              $("#login_in").trigger("click");
          }
      })
  });

  $(document).ready(function () {
      changeCode();
      $("#codeImg").bind("click", changeCode);
  });

  $(document).keyup(function (event) {
      if (event.keyCode == 13) {
          $("#to-recover").trigger("click");
          $("#login_in").trigger("click");
      }
  });

  function genTimestamp() {
      var time = new Date();
      return time.getTime();
  }

  function changeCode() {
      $("#codeImg").attr("src", "<%=basePath%>code.do?t=" + genTimestamp());
  }

  </script>
  
  </body>
</html>